﻿using BLL;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MODEL;
using System.ComponentModel.DataAnnotations;

namespace WebAppUI.Properties
{
    [Route("api/[controller]")]
    [ApiController]
    public class yingxiaoController : ControllerBase
    {
        public yingxiaoController(yingxiaoBLL bll)
        {
            Bll = bll;
        }

        public yingxiaoBLL Bll { get; }


        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="biaoti">标题</param>
        /// <param name="count"></param>
        /// <param name="sum"></param>
        /// <param name="index">页码</param>
        /// <param name="size">页容量</param>
        /// <returns></returns>
        [HttpGet("Showying")]
        public IActionResult Showying(string? biaoti, int index = 1, int size = 2)
        {
            try
            {
                int count = 0;
                int sum = 0;
               var list= Bll.Showying(biaoti, out count, out sum, index, size);
                return Ok(new
                {
                    data=list,
                    count=count,
                    sum=sum,


                });

            }
            catch (Exception ex)
            {

                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id">返回受影响的行数</param>
        /// <returns></returns>
        [HttpDelete("Delying")]
        public int Delying(int id)
        {
            try
            {
                return Bll.Delying(id);
            }
            catch (Exception ex)
            {

                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="yingxiao"></param>
        /// <returns></returns>
        [HttpPut("Upying")]
        public int Upying(yingxiao yingxiao)
        {
            try
            {
                return Bll.Upying(yingxiao);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 反填
        /// </summary>
        /// <returns></returns>
        [HttpGet("fantian")]
        public yingxiao fantian()
        {
            try
            {
                return Bll.fantian();
            }
            catch (Exception)
            {

                throw;
            }
        }





    }
}
